<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/plugins/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="/static/admin/tplay/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="/static/admin/tplay/css/admin.css"  media="all">
</head>

<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li class="layui-this">管理员管理</li>
        <li><a href="{:url('admin/auth/adminAdd')}" class="a_menu">新增管理员</a></li>
      </ul>
    </div>
    <form class="layui-form serch" action="{:url('admin/auth/adminList')}" method="post">
        <div class="layui-form-item" style="float: left;">
          <div class="layui-input-inline">
            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入关键词" class="layui-input layui-btn-sm">
          </div>
          <div class="layui-input-inline">
            <div class="layui-inline">
                <select name="group" lay-search="">
                  <option value="">角色</option>
                  {volist name="$info.group" id="vo"}
                  <option value="{$vo.id}">{$vo.title}</option>
                  {/volist}
                </select>
            </div>
          </div>
          <div class="layui-input-inline">
            <div class="layui-inline">
              <div class="layui-input-inline">
                <input type="text" class="layui-input" id="create_time" placeholder="创建时间" name="create_time">
              </div>
            </div>
          </div>
          <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
        </div>
      </form>
    
    <table class="layui-table" lay-size="sm">
      <colgroup>
        <col width="30">
        <col width="50">
        <col width="80">
        <col width="100">
        <col width="100">
        <col width="120">
        <col width="120">
        <col width="120">
        <col width="80">
        <col width="80">
        <col width="120">
      </colgroup>
      <thead>
        <tr>
          <th>选择</th>
          <th>头像</th>
          <th>角色</th>
          <th>用户名</th>
          <th>真实姓名</th>
          <th>电话</th>
          <th>创建时间</th>
          <th>最后登录时间</th>
          <th>最后登录IP</th>
          <th>状态</th>
          <th>操作</th>
        </tr> 
      </thead>
      <form class="layui-form" id="admin"> 
      <tbody>
        {foreach name="admin" item="vo"}
        <tr>
          <td><input type="checkbox" name="ids[]" value="{$vo.id}" lay-skin="primary"></td>
          <td><a href="{$vo.image}" class="tooltip"><img src="{$vo.image}" width="20" height="20"></a></td>
          <td>{$vo.adminUid.adminGroup.title}</td>
          <td>{$vo.username}</td>
          <td>{$vo.nickname}</td>
          <td>{$vo.tel}</td>
          <td>{$vo.create_time}</td>
          <td>{$vo.login_time|date="Y-m-d H:i:s"}</td>
          <td>{$vo.login_ip}</td>
          <td>
            {if condition="$vo.status eq 1" /}
            <span class="layui-badge layui-bg-orange">正常</span>
            {else /}
            <span class="layui-badge layui-bg-gray">锁定</span>
            {/if}
          </td>
          <td class="operation-menu">
            <div class="layui-btn-group">
              <a href="{:url('admin/auth/adminAdd',['id'=>$vo.id])}" class="layui-btn layui-btn-xs a_menu layui-btn-primary" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary reset" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon">&#xe674</i></a>
              <a class="layui-btn layui-btn-xs status layui-btn-primary" data-id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="fa {if condition="$vo.status eq 1"}fa-toggle-on{else/}fa-toggle-off{/if}"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
            </div>
          </td>
        </tr>
        {/foreach}
      </tbody>
      </form>
    </table>
    <button class="layui-btn layui-btn-sm deletes" lay-submit lay-filter="admin">批量删除</button>
  
    <div style="padding:0 20px;">{$admin|raw}</div>
    
   {include file="foot"}
    <script>
      layui.use(['layer', 'form'], function() {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form;
        form.on('submit(admin)', function(data) {
          layer.confirm('确定要删除?', function(index) {
            $.ajax({
              url:"{:url('admin/auth/adminSelectDel')}",
              data:$('#admin').serialize(),
              type:'post',
              async: false,
              success:function(res) {
                if(res.code == 1) {
                  layer.alert(res.msg, function(index){
                    location.href = res.url;
                  })
                } else {
                  layer.msg(res.msg);
                }
              }
            })
            return false;
          });
        });
      });
    </script>
    <script type="text/javascript">
    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/auth/adminDel')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })
    </script>
    <script type="text/javascript">
      $('.reset').click(function(){
        var id = $(this).attr('id');
        layer.confirm('确定要重置?', function(index) {
          $.ajax({
            url:"{:url('admin/auth/ResetPassword')}",
            data:{id:id},
            success:function(res) {
              layer.msg(res.msg);
              if(res.code == 1) {
                setTimeout(function(){
                  location.href = res.url;
                },1500)
              }
            }
          })
        })
      })
    </script>
    <script type="text/javascript">
      layui.use('layer', function(){
        var layer = layui.layer;
        $('.status').click(function(){
          var id = $(this).attr('data-id');
          layer.msg('管理员状态',{
            time:20000
            ,btn: ['开启', '禁用', '再想想']
            ,yes: function(index, layero){
              $.ajax({
                url:"{:url('admin/auth/adminState')}"
                ,type:'post'
                ,data:{id:id,status:'1'}
                ,success:function(res){
                  layer.msg(res.msg);
                  if(res.code == 1){
                    setTimeout(function(){
                      location.href = res.url;
                    },1500)
                  }
                }
              })
            }
            ,btn2: function(index, layero){
              $.ajax({
                url:"{:url('admin/auth/adminState')}"
                ,type:'post'
                ,data:{id:id,status:'-1'}
                ,success:function(res){
                  layer.msg(res.msg);
                  if(res.code == 1){
                    setTimeout(function(){
                      location.href = res.url;
                    },1500)
                  }
                }
              })
            }
          })
        })
      });              
    </script>
  </div>
</body>
</html>
